package cn.pping.org.service.impl;

import cn.pping.basic.service.impl.BaseServiceImpl;
import cn.pping.org.domain.Employee;
import cn.pping.org.mapper.EmployeeMapper;
import cn.pping.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
// 只读事务
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    @Transactional
    public void save(Employee employee) {
        employeeMapper.save(employee);
        this.update(employee);
    }


    @Override
    public void batch(List<Long> ids) {
        employeeMapper.batch(ids);
    }


    @Override
    public List<Employee> findEmpl(Long id) {
        // 获取到前端的id查找后端的数据
        List<Employee> employees = employeeMapper.loadByDeptId(id);
        System.out.println(employees);


        return employees ;
    }
}
